package com.weimengchao.mybatisplus.mapping;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.weimengchao.core.http.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

@Mapper
public interface PageMapping {

    PageMapping INSTANCE = Mappers.getMapper(PageMapping.class);

    /**
     * @title: mybatis-plus Page 转 PageResult
     * @createAuthor: 魏孟超
     * @createDate: 2021/9/12 23:21
     * @params:
     * @return:
     */
    @Mappings({
            @Mapping(target = "pageNo", source = "current"),
            @Mapping(target = "pageSize", source = "size"),
    })
    PageResult iPage2PageResult(IPage iPage);

    PageResult page2Page(PageResult pageResult);

}
